﻿@{
    Layout = null;
}
<div style="height: 20px; font-weight: bold">
    <b>修改文件夹</b></div>
<div style="padding-top: 50px; padding-bottom: 50px">
@using (Html.BeginForm("SaveFolderUser", "Folder", FormMethod.Post, new { id = "form" }))
{
    <div style="text-align: left; padding: 0px 10px 20px 50px">
        <table style="line-height: 40px" width="400px">
            <tr>
                <td style=" width:150px">
                    @Html.ListBox("lbFUsers", null, new {style = " height:300px; width:150" })
                    @Html.Hidden("hdnAdd")
                    @Html.Hidden("hdnDelete")
                    @Html.Hidden("fid",Request["fid"])
                </td>
                <td style=" vertical-align:middle; text-align:center">
                    <input type="button" id="addfuser" value="添加>>" /><br />
                    <input type="button" id="deletefuser" value="<<删除" />
                </td>
                <td style=" width:150px">@Html.ListBox("lbUsers", null, new { style = " height:300px; width:150" })
                </td>
            </tr>
        </table>
    </div>
    <div style="text-align: center">
        <button id="btnRoles" class="btn"  onclick="save()">保存</button>
    </div>
}
</div>
<script>
    $(".btn").button();
    var addValue = new Array();
    var deleteValue = new Array();
    $(function () {
        $("#addfuser").click(function () {
            if ($("#lbFUsers option:selected").length > 0) {

                $("#lbFUsers option:selected").each(function () {
                    $("#lbUsers").append("<option value='" + $(this).val() + "'>" + $(this).text() + "</option");
                    $(this).remove();
                    addValue.push($(this).val());
                });
                //$("#hdnAdd") = addValue.join(",");
            }
            else {
                alert("请选择要添加的分包！");
            }
        })
    });
    //向左移动
    $(function () {
        $("#deletefuser").click(function () {
            if ($("#lbUsers option:selected").length > 0) {

                $("#lbUsers option:selected").each(function () {
                    $("#lbFUsers").append("<option value='" + $(this).val() + "'>" + $(this).text() + "</option");
                    $(this).remove();
                    deleteValue.push($(this).val());
                });
                //$("#hdnDelete") = deleteValue.join(",");
            }
            else {
                alert("请选择要删除的分包！");
            }
        })
    });
    function save() {
        $("#hdnAdd").val(addValue.join(","));
        $("#hdnDelete").val(deleteValue.join(","));
    }
</script>